import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    testingData: sessionStorage.getItem('testingData') ? JSON.parse(sessionStorage.getItem('testingData')) : {},
    childList: sessionStorage.getItem('childList') ? JSON.parse(sessionStorage.getItem('childList')) : {},
    isShow:  sessionStorage.getItem('isShow') ? JSON.parse(sessionStorage.getItem('isShow')) : false,
  },
  getters: {
    getTestingData: (state) => {
      return state.testingData
    },
    getChildList: (state) => {
      return state.childList
    },
    getIsShow: (state) => {
      return state.isShow
    },
  },
  mutations: {
    setTestingData: (state, list) => {
      state.testingData = list
      sessionStorage.setItem('testingData', JSON.stringify(state.testingData))
    },
    setChildList: (state, list) => {
      state.childList = list
      sessionStorage.setItem('childList', JSON.stringify(state.childList))
    },
    setIsShow: (state, list) => {
      state.isShow = list
      sessionStorage.setItem('isShow', JSON.stringify(state.isShow))
    },
  },
  actions: {
  },
  modules: {
  }
})
